<select name="userId" class="form-control col-8" id="userId" required>
    <option value="">请选择</option>
    <?php foreach($users as $user) : 
        if ((int) $user->id === $userId) : ?>
        <option value="<?php echo $user->id; ?>" selected><?php echo $user->name; ?></option>
        <? else: ?>
        <option value="<?php echo $user->id; ?>"><?php echo $user->name; ?></option>
        <? endif; ?>
    <?php endforeach; ?>
</select>
